import {
    curvePoints, wavePoints, sawtoothPoints, semicirclePoints,
    ellipticalPoints, sinPoints
} from '../math/points/index.js'

import { _type } from '../utils/index.js'

// 曲线函数
export const mapCurve = {
    curve: curvePoints,
    wave: wavePoints,
    sawtooth: sawtoothPoints,
    semicircle: semicirclePoints,
    elliptical: ellipticalPoints,
    sin: sinPoints
}
const getCurveKey = (curve) => {
    let type = _type(curve)
    let key = ""
    if (type === "string") {
        key = curve
    } else if (type === 'object') {
        key = curve.shape || curve.type
    }
    return key
}
export const isCurve = (curve) => {
    let key = getCurveKey(curve)
    return !!mapCurve[key]
}
export const _curve = (points, curve) => {
    let key = getCurveKey(curve)
    return mapCurve[key] ? mapCurve[key](points, curve) : points
}